﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    public class WaitLoadMaterial : CustomYieldInstruction
    {
        private MaterialCache materialcache;
        public Material LoadedObject { get; private set; }
        public string Error { get; private set; }
        internal WaitLoadMaterial(MaterialCache mat)
        {
            this.materialcache = mat;
        }

        public override bool keepWaiting
        {
            get
            {
                if (!string.IsNullOrEmpty(this.materialcache.Error))
                {
                    this.Error = this.materialcache.Error;
                    return false;
                }
                if (this.materialcache.IsNotNull())
                {
                    this.LoadedObject = this.materialcache.GetObject();
                    return false;
                }
                return true;
            }
        }



    }
}


